home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / RxMUI / Examples / Clock.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2004-01-31  |  4.1 KB  |  140 lines

  1. /*A clock */
  2.  
  3. signal on halt
  4. signal on break_c
  5. call init
  6. call CreateApp
  7. call handleApp
  8. /* never reached */
  9. /***********************************************************************/
  10. init:procedure expose global.
  11.     l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  12.     if AddLibrary("rexxsupport.library","rxmui.library")~=0 then exit
  13.  
  14.     global.tim=CreateTimer()
  15.     global.ts=TimerSignal(global.tim)
  16.  
  17.     global.DateFormats.0="%A %e %b %Y"
  18.     global.DateFormats.1="%A %b %e %Y"
  19.     global.DateFormats.2="%e/%m/%Y"
  20.     global.DateFormats.3="%m/%e/%Y"
  21.  
  22.     global.TimeFormats.0="%H:%M:%S"
  23.     global.TimeFormats.1="%I:%M:%S %p"
  24.  
  25.     global.DateFormat=0
  26.     global.TimeFormat=0
  27.  
  28.     global.NewDateFormat=0
  29.     global.NewTimeFormat=0
  30.  
  31.     global.ChangeDateFormat=0
  32.     global.ChangeTimeFormat=0
  33.  
  34.     return
  35. /***********************************************************************/
  36. HandleApp: procedure expose global.
  37.     ctrl_c=2**12
  38.     sig=or(ctrl_c,global.ts)
  39.     call StartTimer(global.tim,0,900000)
  40.     do forever
  41.         call NewHandle("app","h",sig)
  42.         if and(h.signals,ctrl_c)>0 then exit
  43.         if and(h.signals,global.ts)>0 then do
  44.             call RefreshTime()
  45.             call StartTimer(global.tim,0,900000)
  46.         end
  47.         if h.EventFlag then
  48.             select
  49.                 when h.event="QUIT" then exit
  50.                 otherwise interpret h.event
  51.             end
  52.         end
  53.     end
  54.     /* never reached */
  55. /***********************************************************************/
  56. CreateApp: procedure expose global.
  57.  
  58.     app.title="Clock"
  59.     app.version="$VER: Clock 1.1 (25.1.2002)"
  60.     app.copyright="©2002 by alfie"
  61.     app.author="alfie"
  62.     app.description="Clock"
  63.     app.base="CLOCK"
  64.     app.SubWindow="win"
  65.  
  66.      win.ID="MAIN"
  67.      win.title="Clock"
  68.      win.contents="mgroup"
  69.  
  70.       call child("mgroup","vg","group")
  71.        call child("vg","popd","popobject")
  72.         popd.object="popdlv"
  73.          popdlv.class="listview"
  74.          popdlv.list="dflist"
  75.           dflist.frame="inputlist"
  76.            dflist.0="DayName DayNum MonthName Year"
  77.            dflist.1="DayName Month DayNum Year"
  78.            dflist.2="DayName/MonthName/Year"
  79.            dflist.3="MonthName/DayName/Year"
  80.         popd.string=text("date","")
  81.         popd.button=MakeObj("","Imagebutton","popup")
  82.         popd.toggle=1
  83.  
  84.        call child("vg","popt","popobject")
  85.         popt.object="poptlv"
  86.          poptlv.class="listview"
  87.          poptlv.list="tflist"
  88.           tflist.frame="inputlist"
  89.            tflist.0="24 hours"
  90.            tflist.1="Am/Pm"
  91.         popt.string=text("time","")
  92.         popt.button=MakeObj("","Imagebutton","popup")
  93.         popt.toggle=1
  94.  
  95.     if NewObj("application","app")>0 then exit
  96.  
  97.     call notify("win","CloseRequest",1,"app","ReturnID","QUIT")
  98.  
  99.     call notify("dflist","doubleclick","everytime","popd","close",1)
  100.     call notify("dflist","doubleclick","everytime","app","setvar","GLOBAL.CHANGEDATEFORMAT")
  101.     call notify("dflist","active","everytime","app","setvar","GLOBAL.NEWDATEFORMAT")
  102.  
  103.     call notify("tflist","doubleclick","everytime","popt","close",1)
  104.     call notify("tflist","doubleclick","everytime","app","setvar","GLOBAL.CHANGETIMEFORMAT")
  105.     call notify("tflist","active","everytime","app","setvar","GLOBAL.NEWTIMEFORMAT")
  106.  
  107.     call RefreshTime()
  108.  
  109.     call set("win","open",1)
  110.  
  111.     return
  112. /***********************************************************************/
  113. halt:
  114. break_c:
  115.     exit
  116. /**************************************************************************/
  117. RefreshTime: procedure expose global.
  118.     call GetDate("NOW")
  119.  
  120.     if global.ChangeTimeFormat then do
  121.         global.ChangeTimeFormat=0
  122.         global.TimeFormat=global.NewTimeFormat
  123.     end
  124.     tf=global.TimeFormat
  125.     time=FormatDate("NOW",global.TimeFormats.tf)
  126.     call set("time","contents",time)
  127.  
  128.     if global.ChangeDateFormat then do
  129.         global.ChangeDateFormat=0
  130.         global.DateFormat=global.NewDateFormat
  131.     end
  132.     df=global.DateFormat
  133.     date=FormatDate("NOW",global.DateFormats.df)
  134.     if global.OldDate~=date then do
  135.         call set("date","contents",date)
  136.         global.OldDate=date
  137.     end
  138.     return
  139. /***************************************************************************/
  140.